<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

class Timkiem_lophoc extends CI_Controller {

    public function __construct() {
        parent::__construct();
        $this->load->model('display_model');
    }

    function render($path, $data) {
        $this->load->view('user/common/header_view');
        $this->load->view('user/common/left_sidebar_view');
        $this->load->view('user/common/seach_view_giasu',$data);
        $this->load->view($path, $data);
        $this->load->view('user/common/right_sidebar_view');
        $this->load->view('user/common/footer_view');
    }

    public function getTrinhDo($idTrinhDo) {
        //todo
        return 0;
    }

    public function index() {


        $TenThanhVien = $this->input->post('ten');
        $idTrinhDo = $this->input->post('trinhdo'); //1: Cao đẳng ; 2: Đại học ; 3: Thạc Sỹ
        $idGioiTinh = $this->input->post('gioitinh'); //: khong xác định ; 1: Nam ; 2: Nữ
        
        if (isset($_POST['option'])){
            $TenMonHoc = $_POST['option'];
        }  else {
            $TenMonHoc = [];
        }
        
        //Phan trang
        $this->load->model('timkiem_lophoc_model');
       
        $this->load->library('pagination');
        $config['base_url'] = base_url().'index.php/timkiem/timkiem_lophoc/index';
        $config['total_rows'] =  $this->timkiem_lophoc_model->index($TenThanhVien, $idTrinhDo, $idGioiTinh, $TenMonHoc,NULL,NULL);
        $config['per_page'] = 10; //records
        $config['uri_segment'] = 4;
        $config['num_links'] = 10;
        $config['next_link'] = 'Next »'; 
        $config['prev_link'] = '« Prev';    
        $config['full_tag_open'] = '<ul class="pagination">';
        $config['full_tag_close'] = '</ul>';       
        $config['prev_tag_open'] = '<li>';
        $config['prev_tag_close'] = '</li>';
        $config['next_link'] = '&raquo;';
        $config['next_tag_open'] = '<li>';
        $config['next_tag_close'] = '</li>';
        $config['cur_tag_open'] = '<li class="active"><a href="#">';
        $config['cur_tag_close'] = '</a></li>';
        $config['num_tag_open'] = '<li>';
        $config['num_tag_close'] = '</li>';;
        
        $this->pagination->initialize($config);

        $data = $this->timkiem_lophoc_model->index($TenThanhVien, $idTrinhDo, $idGioiTinh, $TenMonHoc,$config['per_page'], $this->uri->segment(4));
        
        $data['data'] = $data;

        $data['link']=$this->pagination->create_links();
        $data['path'] = 'timkiem/timkiem_lophoc';
        
        $this->load->model('timkiem_giasu_model');      
        $data['TrinhDo'] =  $this->timkiem_giasu_model->getTrinhDo();       
        $data['NganhHoc'] = $this->timkiem_giasu_model->getNganhHoc();       
        $data['MonHoc'] = $this->timkiem_giasu_model->getMonHoc();
        
        $data['iten'] = $TenThanhVien;
        $data['itrinhdo'] = $idTrinhDo;
        if($idGioiTinh == NULL)
           $data['igioitinh'] = '';
        else $data['igioitinh'] = $idGioiTinh;
        $data['imonhoc'] = $TenMonHoc;
        
        $this->render('timkiem/timkiem_lophoc_view', $data);
    }
}